﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using WeiTap.Data;
using WeiTap.Test.UserManager;

namespace WeiTap.WebApi.Test.UserManager
{
    public static class UserDa
    {
        /// <summary>
        /// 新增用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static async Task<object> InsertUser(User user)
        {
            using (var db = new Database())
            {
               var result =await db.InsertAsync(user);
                Trace.WriteLine($"插入结果:{result}");
                return result;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static async Task<IList<User>> GetUsersAsync()
        {
            using (var db=new Database())
            {
                return await db.FetchAsync<User>("select * from user");
            }
        }
    }
}